import json
import utils.env_conf

import matplotlib.pyplot as plt

data = [
    {
        "name": "SI",
        "time": ["2023-07-10", "2023-07-11", "2023-07-12", "2023-07-13"],
        "a": [1.1, 1.4, 1.2, 1.7],
        "b": [0.8, 1.7, 0.9, 1]
    },
    {
        "name": "GI",
        "time": ["2023-07-10", "2023-07-11", "2023-07-12", "2023-07-13"],
        "a": [1.4, 1.0, 1.2, 1.1],
        "b": [0.77, 0.98, 1.6, 1.1]
    },
]

import os
import openai
respinse = openai.Image.create(
  prompt="根据数据生成折线图,"+json.dumps(data),
  n=2,
  size="1024x1024"
)
print(respinse)


# # Extract data for plotting
# names = [item["name"] for item in data]
# time = data[0]["time"]  # Assuming all items have the same time axis
# a_values = {item["name"]: item["a"] for item in data}
# b_values = {item["name"]: item["b"] for item in data}
#
# # Create the plot
# plt.figure(figsize=(10, 6))
# plt.title("Values 'a' and 'b' over time")
# plt.xlabel("Time")
# plt.ylabel("Values")
# plt.xticks(range(len(time)), time, rotation=45)
#
# # Plot 'a' values for each name
# for name in names:
#     plt.plot(a_values[name], marker='o', label=f"{name} - 'a'")
#
# # Plot 'b' values for each name
# for name in names:
#     plt.plot(b_values[name], marker='x', label=f"{name} - 'b'")
#
# # Add legend
# plt.legend()
#
# # Display the plot
# plt.tight_layout()
# plt.show()
